﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class newsList : System.Web.UI.Page
{
    public string strcr = "";

    protected void Page_Load(object sender, EventArgs e)
    {
        db_news news = new db_news();
        DataSet ds = news.selectNewsALLOpen();
        //ds = news.selectNewsALL();
        //分页 开始 -------
        int CurPage;
        if (Request.QueryString["Page"] != null && Convert.ToInt32(Request.QueryString["Page"]) > 0)
            CurPage = Convert.ToInt32(Request.QueryString["Page"]);
        else
            CurPage = 1;
        PagedDataSource ps = new PagedDataSource();
        ps.DataSource = ds.Tables[0].DefaultView;
        ps.AllowPaging = true;
        //每个页面显示的条数
        ps.PageSize = 15;
        onePage.Text = ps.PageSize.ToString();
        //求数据的总数
        allMsg.Text = ps.DataSourceCount.ToString();
        ps.CurrentPageIndex = CurPage - 1;
        //求总页
        allPages.Text = ps.PageCount.ToString();
        nowPage.Text = CurPage.ToString();
        //将数据源与控件绑定
        list.DataSource = ps;
        list.DataBind();

        //上一页
        if (!ps.IsFirstPage)
        {
            firstPage.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=1";
            prePage.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(CurPage - 1);
        }
        //下一页
        if (!ps.IsLastPage)
        {
            nextPage.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(CurPage + 1);
            endPage.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(ps.PageCount);
        }
        //分页 结束 -------

        DataSet hit = new DataSet();
        hit = news.selectNewsALLTop_hit("10");
        hit_list.DataSource = hit.Tables[0].DefaultView;
        hit_list.DataBind();
  

        db_blogroll blogroll = new db_blogroll();
        DataSet ds_blogroll = blogroll.selectBlogrollALL();
        blogrollList.DataSource = ds_blogroll.Tables[0].DefaultView;
        blogrollList.DataBind();

        db_copyright cr = new db_copyright();
        DataSet dscr = cr.selectOne();
        strcr = "Copyright &copy; " + dscr.Tables[0].Rows[0]["cryear"].ToString() + " " + dscr.Tables[0].Rows[0]["owner"].ToString() + " ALL Rights Reserved<br/><a href=\"http://www.miibeian.gov.cn\" target=\"_blank\">" + dscr.Tables[0].Rows[0]["approve"].ToString() + "</a>";
    }
}
